package com.erp.domain;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import com.erp.dto.Forum;
import com.erp.mapping.Status;

@SuppressWarnings("serial")
@Entity
@Table(name = "t_forum")
public class TForum implements java.io.Serializable {

	private Integer id;
	private String name;
	private Integer orderNumber;
	private String description;
	private Integer topicCount = 0; // 主题数，需手动维护，默认0
	private Status status = Status.STATUS_NORMAL;// 板块状态，默认正常状态
	private List<TTopic> tTopics = new ArrayList<TTopic>();

	public TForum() {
	}

	public TForum(Forum forum) {
		this.id = forum.getId();
		this.name = forum.getName();
		this.orderNumber = forum.getOrderNumber();
		this.description = forum.getDescription();
		this.topicCount = forum.getTopicCount();
		this.status = forum.getStatus();
	}

	@Id
	@GeneratedValue
	@Column(name = "id")
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@Column(name = "name")
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(name = "order_number")
	public Integer getOrderNumber() {
		return orderNumber;
	}

	public void setOrderNumber(Integer orderNumber) {
		this.orderNumber = orderNumber;
	}

	@Column(name = "description")
	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	@Column(name = "topicCount")
	public Integer getTopicCount() {
		return topicCount;
	}

	public void setTopicCount(Integer topicCount) {
		this.topicCount = topicCount;
	}

	@Enumerated(EnumType.ORDINAL)
	@Column(name = "status")
	public Status getStatus() {
		return status;
	}

	public void setStatus(Status status) {
		this.status = status;
	}

	/**
	 * 本类与TTopic的一对多双向关系，tForum为映射属性
	 * 
	 * @return
	 */
	@OneToMany(mappedBy = "tForum")
	public List<TTopic> gettTopics() {
		return tTopics;
	}

	public void settTopics(List<TTopic> tTopics) {
		this.tTopics = tTopics;
	}

}
